/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.entity;

import org.ipti.br.tag.entity.enums.AskTypes;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.ipti.br.tag.util.EncryptionUtil;

/**
 *
 * @author ipti
 */
@Entity
public class Asks extends AbstractEntity{
    
    @Column(name = "name")
    private String name;
    
    @Enumerated(EnumType.ORDINAL)
    private AskTypes askTypes;
    
    @Column(name = "measure_unity")
    private String measureUnity;
    
    @Column(name = "data_type")
    private String dataType;

    @ManyToOne
    @JoinColumn(name = "question_id")
    private Questions questions;
    
    public Asks() {
    }

    @Override
    public void generateHash(){
        if(getId() == null){
            String hash = "" + this.getName() + this.getAskTypes() + this.getDataType();
            this.setId(Long.valueOf(EncryptionUtil.encrypt(hash).hashCode()));
        }
    }

    public Asks(String name, AskTypes askTypes, String measureUnity, String dataType, Questions questions) {
        this.name = name;
        this.askTypes = askTypes;
        this.measureUnity = measureUnity;
        this.dataType = dataType;
        this.questions = questions;
    }

    public AskTypes getAskTypes() {
        return askTypes;
    }

    public void setAskTypes(AskTypes askTypes) {
        this.askTypes = askTypes;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMeasureUnity() {
        return measureUnity;
    }

    public void setMeasureUnity(String measureUnity) {
        this.measureUnity = measureUnity;
    }

    public Questions getQuestions() {
        return questions;
    }

    public void setQuestions(Questions questions) {
        this.questions = questions;
    }
}
